import request from '../../api/base'
import orderBy from 'lodash/orderBy';
import moment from 'moment';

export function checkPwd(pwd) {
  return  request({
    method: 'post',
    url: 'api/member/api-member/member/checkPwd',
    data: {pwd},
    requestType: 'form'
  }).then(res => {
    return res;
  })
}

export function getEmployeeSalary(data) {
  return  request({
    method: 'post',
    url: 'api/member/api-member/member/getEmployeeSalary',
    data: {...data},
    requestType: 'form'
  }).then(res => {
    const data = res.data;
    const newList = data.list.map((item)=>{
      let time = item.month.replace('年','-').replace('月','')
      return {...item, time:moment(time,'YYYY-M').format('YYYY-MM')}
    })
    return {
      ...res,
      data:{
        ...res.data,
        list:orderBy(newList,['time'], ['desc'])
      }

    };
  })
}

export function getEmployeeSalaryModule(authToken) {
  return  request({
    method: 'get',
    url: 'api/member/api-member/member/getEmployeeSalaryModule',
    data: {authToken},
    requestType: 'form'
  }).then(res => {
    if (res.flag && res.data.length>0){
      return res.data[0]
    }
    return {};
  })
}



